package com.example.auth.utils;


import com.example.auth.constants.CommonConstants;
import com.example.auth.model.Result;

import java.util.Map;


/**
 * Created by wangtao on 2018/3/7.
 */
public class ResultUtil {

    public static Result success(Object data) {
        Result result = new Result();
        result.setCode(CommonConstants.SUCCESS);
        result.setData(data);
        return result;
    }

    public static Result success(Object data, Map params) {
        Result result = new Result();
        result.setCode(CommonConstants.SUCCESS);
        result.setData(data);
        result.setParams(params);
        return result;
    }

    public static Result fail(String msg) {
        Result result = new Result();
        result.setCode(CommonConstants.FAILURE);
        result.setMsg(msg);
        return result;
    }

    public static Result fail(String msg, int code) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
}
